package org.koalaui.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

/**
 * Servlet implementation class MenuServlet
 */
public class MenuServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public MenuServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		Map params = request.getParameterMap();
//		System.out.println(this.getClass().getResource("/").getPath());
		
		String json = "[{\"parentId\":\"root\",\"menu\":{\"id\":\"001\",\"title\":\"权限管理\"," +
				"\"href\":\"#\"},\"children\":{\"001001\":{\"parentId\":\"001\",\"menu\":" +
				"{\"id\":\"001001\",\"title\":\"用户管理\",\"href\":\"#\"},\"children\":" +
				"{\"001001001\":{\"parentId\":\"001001\",\"menu\":{\"id\":\"001001001\"," +
				"\"title\":\"添加新用户123\",\"href\":\"#\"},\"children\":{}},\"001001002\":" +
				"{\"parentId\":\"001001\",\"menu\":{\"id\":\"001001002\",\"title\":\"系统用户查询\"," +
				"\"href\":\"#\"},\"children\":{}}}},\"001002\":{\"parentId\":\"001\",\"menu\":{\"id\"" +
				":\"001002\",\"title\":\"角色管理\",\"href\":\"#\"},\"children\":{\"001002001\":{" +
				"\"parentId\":\"001002\",\"menu\":{\"id\":\"001002001\",\"title\":\"添加新角色\"," +
				"\"href\":\"#\"},\"children\":{}},\"001002002\":{\"parentId\":\"001002\",\"menu\":{" +
				"\"id\":\"001002002\",\"title\":\"用户角色配置\",\"href\":\"#\"},\"children\":{}}" +
				",\"001002003\":{\"parentId\":\"001002\",\"menu\":{\"id\":\"001002003\",\"title\":" +
				"\"角色权限配置\",\"href\":\"#\"},\"children\":{}}}},\"001003\":{\"parentId\":\"001\"," +
				"\"menu\":{\"id\":\"001003\",\"title\":\"菜单管理\",\"href\":\"#\"},\"children\":{}}}}," +
				"{\"parentId\":\"root\",\"menu\":{\"id\":\"002\",\"title\":\"系统管理\",\"href\":\"#\"}," +
				"\"children\":{\"002001\":{\"parentId\":\"002\",\"menu\":{\"id\":\"002001\",\"title\":" +
				"\"功能配置\",\"href\":\"#\"},\"children\":{}},\"002002\":{\"parentId\":\"002\",\"menu\"" +
				":{\"id\":\"002002\",\"title\":\"系统访问记录\",\"href\":\"#\"},\"children\":{}}}},{\"parentId\"" +
				":\"root\",\"menu\":{\"id\":\"003\",\"title\":\"日志管理\",\"href\":\"#\"},\"children\":{" +
				"\"003001\":{\"parentId\":\"003\",\"menu\":{\"id\":\"003001\",\"title\":\"日志查询\"," +
				"\"href\":\"#\"},\"children\":{}}}}];";
		
		response.setContentType("text/xml;charset=UTF-8");  
		response.setHeader("Cache-Control", "no-cache");  
		PrintWriter out = response.getWriter();
		out.write(json);
		out.flush();
		out.close();
	}

}
